﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Viper;

namespace vrt
{
    class Program
    {
        static void Main(string[] args)
        {   
            viperv3.ViperVirtualMachine vm = new viperv3.ViperVirtualMachine();
            if (args.Length > 0)
            {
                Assembly asm = new Assembly();
                asm.LoadGEX(args[0]);
                
                vm.Run(asm);
            }
            else
            {
                Viper.Assembler asmc = new Viper.Assembler();
                string code = "";
                int i = 0;
                while (true)
                {
                    if (i.ToString().Length == 2)
                    {
                        Console.Write("0" + i.ToString() + ":");
                    }
                    if (i.ToString().Length == 1)
                    {
                        Console.Write("00" + i.ToString() + ":");
                    }
                    string asm = Console.ReadLine();
                    if (asm != "run")
                    {

                        code += asm + "\n";
                    }
                    else
                    {
                        break;
                    }
                    i++;

                }
                asmc.Assemble(code);
                vm = new viperv3.ViperVirtualMachine();
                vm.Run(asmc.assembly);
                asmc.assembly.CreateGEX("test.gex");
                Console.ReadLine();
            }

       
        }
    }
}
